package com.example.farmer.Setting;

import android.os.Bundle;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.farmer.R;

public class PrivacyActivity extends AppCompatActivity {

    private Switch setting_switch;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_privacy);

        setting_switch = findViewById(R.id.setting_switch);
        setting_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    Toast.makeText(PrivacyActivity.this, "已开启", Toast.LENGTH_SHORT).show();

                }else if (!isChecked){
                    Toast.makeText(PrivacyActivity.this, "已关闭", Toast.LENGTH_SHORT).show();

                }
            }
        });

    }
    public void onSaveClick(View view) {
        // 这里添加保存数据的逻辑
        // 例如，调用productHelper.addProduct(...);

        // 假设数据保存成功，显示Toast消息
        Toast.makeText(this, "保存成功", Toast.LENGTH_SHORT).show();

        // 关闭当前Activity并返回上一个页面
        finish();
    }
}
